//
//  getPondTissueListModel.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/23.
//

#import "getPondTissueListModel.h"

@implementation getPondTissueListModel

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{
        @"ID":@[@"id"],
        @"children":@[@"children",@"childList"],
    };
}

+ (NSDictionary *)modelContainerPropertyGenericClass {
    return @{
        @"children":[getPondTissueListModel class],
    };
}


- (CGFloat)cellW {
    if(_cellW == 0){
        _cellW = [DTKTool textWithtitle:self.name andSize:CGSizeMake(1000, 100) andFout:kCFont(17)].width + kwt(60);
        if(_cellW < kwt(115)){
            _cellW = kwt(115);
        }
    }
    return _cellW;
}
- (CGFloat)childrenMaxcellW {
    if(_childrenMaxcellW == 0){
        for (getPondTissueListModel *model in self.children) {
            if(_childrenMaxcellW < model.cellW){
                _childrenMaxcellW = model.cellW;
            }
        }
    }
    return _childrenMaxcellW;
}

- (BOOL)islast{
    return self.children.count < 1;
}
- (void)allNoSeled {
    for (getPondTissueListModel *model in self.children) {
        [model allNoSeled];
        if(model.islast){
            model.seled = NO;
        }
    }
}


- (void)childrenModelWithModel:(getPondTissueListModel *)model SetSeled:(BOOL)isSeled{
    for (getPondTissueListModel * cm in self.children) {
        if(cm == model){
            cm.seled = isSeled;
            return;
        } else {
            [cm childrenModelWithModel:model SetSeled:isSeled];
        }
    }
    
}
- (BOOL)modelWithSeledID:(NSString *)ID{
    for (getPondTissueListModel * model in self.children) {
        if([model.ID isEqualToString:ID]){
            model.seled = YES;
            return YES;
        }
        model.seled = [model modelWithSeledID:ID];
    }
    
    return NO;
}
- (NSMutableArray <getPondTissueListModel *> *)modelArray{
    NSMutableArray * modelArray = [NSMutableArray array];
    for (getPondTissueListModel * model in self.children) {
        [modelArray addObjectsFromArray:[model modelArray]];
        [modelArray addObject:model];
    }
    return modelArray;
}
//- (NSMutableArray <getPondTissueListModel *> *)AllModelArray{
//    NSMutableArray * array = [NSMutableArray array];
//    for (getPondTissueListModel * cm in self.children) {
//        if(cm.seled){
//            if(self.TJname.length > 0){
//                cm.TJname = [NSString stringWithFormat:@"%@-%@",self.TJname,cm.name];
//            } else {
//                cm.TJname = cm.name;
//            }
//            BOOL isHaveSeled = NO;
//            for (getPondTissueListModel * minm in [cm AllModelArray]) {
//                if(minm.seled){
//                    isHaveSeled = YES;
//                }
//            }
//            if(isHaveSeled == NO){
//                [array addObject:cm];
//            }
//        }
//        [array addObjectsFromArray:[cm AllModelArray]];
//    }
//    return array;
//}
- (getPondTissueListModel *)seledModel {
    for (getPondTissueListModel * cm in self.children) {
        if(cm.seled){
            if([cm seledModel]){
                if(self.TJname.length > 0){
                    cm.TJname = [NSString stringWithFormat:@"%@-%@",self.TJname,cm.name];
                } else {
                    cm.TJname = cm.name;
                }
                return [cm seledModel];
            }
            if(self.TJname.length > 0 ){
                cm.TJname = [NSString stringWithFormat:@"%@-%@",self.TJname,cm.name];
            } else {
                cm.TJname = cm.name;
            }
            return cm;
        }
    }
  
    return nil;
}
@end
@implementation templateOptionListModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"ID":@[@"id"],
    };
}
@end
@implementation PositionUserModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"ID":@[@"id"],
    };
}
+ (NSDictionary *)modelContainerPropertyGenericClass {
    return @{
        @"userModelList":[PondUserModel class],
    };
}

@end


@implementation PondUserModel
@end
